

import React, { Component } from 'react'

export default class index extends Component {

  constructor(props){
    super(props);
    this.parent = null;
  }

  chuan=(str)=>{
    console.log("传来的值",str);
  }


  fnSon=()=>{
    this.parent.fnParent("hi，我是儿子");
  }
  
  
  componentDidMount(){
    this.props.onRef(this);
  }


  render() {
    return (
      <div>
        <h1>子组件</h1>
        <input type="button" value="传给父亲" onClick={this.fnSon} />
      </div>
    )
  }
}
